--- import Breadcrumbs from '@/components/Breadcrumbs.astro' import Container from '@/components/Container.astro' import PostNavigation from '@/components/PostNavigation.astro' import TableOfContents from '@/components/TableOfContents.astro' import { badgeVariants } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Separator } from '@/components/ui/separator' import Layout from '@/layouts/Layout.astro' import { formatDate, parseAuthors, readingTime } from '@/lib/utils' import { Icon } from 'astro-icon/components' import { Image } from 'astro:assets' import { type CollectionEntry, getCollection } from 'astro:content' export async function getStaticPaths() { const posts = (await getCollection('blog')) .filter((post) => !post.data.draft) .sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf()) return posts.map((post) => ({ params: { slug: post.slug }, props: post, })) } type Props = CollectionEntry<'blog'> const posts = (await getCollection('blog')) .filter((post) => !post.data.draft) .sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf()) function getPostIndex(slug: string): number { return posts.findIndex((post) => post.slug === slug) } function getNextPost(slug: string): Props | null { const postIndex = getPostIndex(slug) return postIndex !== -1 && postIndex < posts.length - 1 ? posts[postIndex + 1] : null } function getPrevPost(slug: string): Props | null { const postIndex = getPostIndex(slug) return postIndex > 0 ? posts[postIndex - 1] : null } const currentPostSlug = Astro.params.slug const nextPost = getNextPost(currentPostSlug) const prevPost = getPrevPost(currentPostSlug) const post = Astro.props const { Content, headings } = await post.render() const authors = await parseAuthors(post.data.authors ?? []) --- { post.data.image && ( {post.data.title} ) }

{post.data.title}

{formatDate(post.data.date)} {readingTime(post.body)}
{ post.data.tags && post.data.tags.length > 0 ? ( post.data.tags.map((tag) => ( {tag} )) ) : ( No tags available ) }
{headings.length > 0 && }